package com.zhang.controller.order;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhang.common.util.result.R;
import com.zhang.common.util.result.RUtils;
import com.zhang.order.dto.AppraiseSearchDTO;
import com.zhang.order.service.IGoodsAppraiseService;
import com.zhang.order.vo.AppraiseCountVO;
import com.zhang.order.vo.OrderAppraiseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品评价表 前端控制器
 * </p>
 *
 * @author 创世神
 * @since 2024-04-20
 */
@RestController
@RequestMapping("/order/goodsAppraise")
public class GoodsAppraiseController {
    @Autowired
    private IGoodsAppraiseService goodsAppraiseService;

    @PostMapping("save")
    public R saveAppraise(@RequestBody List<OrderAppraiseVo> orderAppraiseVos) {
        goodsAppraiseService.saveAppraise(orderAppraiseVos);
        return RUtils.successMsg("评价成功！");
    }

    @GetMapping("list/skuId")
    public R getAppraiseListBySkuId(AppraiseSearchDTO dto) {
        AppraiseCountVO vo= goodsAppraiseService.getCountBySkuId(dto);
        return RUtils.successData(vo);
    }
}
